home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 18 / CU Amiga Magazine's Super CD-ROM 18 (1997)(EMAP Images)(GB)[!][issue 1998-01].iso / CUCD / Programming / AmigaE / Src / OOmodules / Coordinate / line.e < prev    next >
Encoding:
Text File  |  1995-05-20  |  1.6 KB  |  101 lines

  1. /*
  2.  
  3. This is a 'reducing' way to implement the Line: the attributes x, y and z
  4. are used as starting values, they may be used. Therefore, start is removed
  5.  
  6. Look at the rotate procs and see the powerful way of coding oo :)
  7. */
  8.  
  9. OPT MODULE
  10. OPT EXPORT
  11.  
  12. MODULE 'oomodules/coordinate','oomodules/sort/numbers/float'
  13.  
  14. OBJECT line OF coordinate
  15.   end:PTR TO coordinate
  16. ENDOBJECT
  17.  
  18. PROC name() OF line IS 'Line'
  19.  
  20. PROC init() OF line
  21. DEF coo:PTR TO coordinate,
  22.     float_x:PTR TO float,
  23.     float_y:PTR TO float,
  24.     float_z:PTR TO float
  25.  
  26.   NEW float_x.new()
  27.   self.x := float_x
  28.  
  29.   NEW float_y.new()
  30.   self.y := float_y
  31.  
  32.   NEW float_z.new()
  33.   self.z := float_z
  34.  
  35.   NEW coo.new()
  36.   self.end := coo
  37.  
  38. ENDPROC
  39.  
  40. PROC end() OF line
  41. DEF coo:PTR TO coordinate,flt:PTR TO float
  42.  
  43.   flt := self.x
  44.   END flt
  45.  
  46.   flt := self.y
  47.   END flt
  48.  
  49.   flt := self.z
  50.   END flt
  51.  
  52.   coo := self.end
  53.   END coo
  54.  
  55. ENDPROC
  56.  
  57.  
  58. PROC select(optionlist,index) OF line
  59. /*
  60.  
  61. TODO: error check: len-o'-list!
  62.  
  63.  
  64. DEF item, value
  65.  
  66.   item := ListItem(optionlist, index)
  67.  
  68.   SELECT item
  69.     CASE "set"
  70.  
  71.     INC index
  72.   ENDSELECT
  73. */
  74. ENDPROC index
  75.  
  76.  
  77. PROC setStart(coo:PTR TO coordinate) OF line
  78.  
  79.   self.setX( coo.getX() )
  80.   self.setY( coo.getY() )
  81.   self.setZ( coo.getZ() )
  82.  
  83. ENDPROC
  84.  
  85. PROC setEnd(coo:PTR TO coordinate) OF line IS coo.copy(self.end)
  86.  
  87. PROC rotateZ(angle, at=NIL:PTR TO coordinate) OF line
  88.   self.end.rotateZ(angle,at)
  89.   SUPER self.rotateZ(angle,at)
  90. ENDPROC
  91.  
  92. PROC rotateY(angle, at=NIL:PTR TO coordinate) OF line
  93.   self.end.rotateY(angle,at)
  94.   SUPER self.rotateY(angle,at)
  95. ENDPROC
  96.  
  97. PROC rotateX(angle, at=NIL:PTR TO coordinate) OF line
  98.   self.end.rotateX(angle,at)
  99.   SUPER self.rotateX(angle,at)
  100. ENDPROC
  101.